package com.haohuo.question1;

import java.util.*;

/**
 * 测试类
 * note：
 * <p>
 **/
public class Test {
    private static Scanner input = new Scanner(System.in);
    private static Map<String, Content> allContent = new HashMap<String, Content>(16);


    /**
     * 测试入口
     * @param args
     */
    public static void main(String[] args) {
        simpleTest();
    }

    private static void init() {
        System.out.println("正在初始化..");
        allContent.put("C1", new Content("C1", Arrays.asList("a", "b")));
        allContent.put("C2", new Content("C2", Arrays.asList("b", "c", "d")));
        allContent.put("C3", new Content("C3", Arrays.asList("e", "f")));
        allContent.put("C4", new Content("C4", Arrays.asList("a", "g")));
        allContent.put("C5", new Content("C5", Arrays.asList("g", "d")));
        allContent.put("C6", new Content("C6", Arrays.asList("f", "b")));
        allContent.put("C7", new Content("C7", Arrays.asList("c", "g")));
        allContent.put("C8", new Content("C8", Arrays.asList("g", "f")));
        allContent.put("C9", new Content("C9", Arrays.asList("d", "e")));
    }

    /**
     * 简单测试
     */
    private static void simpleTest() {
        // 初始化系统全部内容
        init();

        User user = new User("张三");
        boolean flag = true;
        while (flag) {
            System.out.println("---------------------------------------------------");
            System.out.println("请选择点击内容 (C1 - C9)：\n(输入exit退出)");
            String next = input.next();

            if ("exit".equalsIgnoreCase(next)) {
                System.out.println("键入exit，程序退出！");
                break;
            }

            Content content = allContent.get(next);

            if (content == null) {
                System.out.println("不存在的内容，请重新输入");
                continue;
            }
            user.checkContent(content);
            System.out.println("记录成功");
        }
        System.out.println("---------------------------------------------------");
        System.out.println(String.format("用户：%s\n标签：%s", user.getUsername(), user.out()));
        System.out.println("---------------------------------------------------");
    }

}
